﻿package com.eaglesandcobras.games.questions{
	import com.eaglesandcobras.games.questions.Question;
	import flash.events.MouseEvent;
	
	public class SingleAnswerQuestion extends Question{
		
		public function SingleAnswerQuestion() {
			super();
		}
		
		public function set correct($c:int):void {
			answers[$c-1].correct = true;
			
			for ( var i=0;i<answers.length;i++) {
				answers[i].addEventListener(MouseEvent.CLICK, answerClick);
			}
		}
		
		private function answerClick(e:MouseEvent):void {
			questionContent.visible = false;
			
			if (e.target.correct) {
				correctClip.visible = true;
				correctClip.y = bg.height/2-correctClip.height/2;
				correctClip.x = bg.width/2-correctClip.width/2;
			} else {
				incorrectClip.visible = true;
				incorrectClip.y = bg.height/2-incorrectClip.height/2;
				incorrectClip.x = bg.width/2-incorrectClip.width/2;
			}
		}
		

	}
}
